
import moment from "moment";

export const pickerOptions={
  shortcuts: [
    {
      text: "当天",
      onClick(picker) {
        const end = moment().format("YYYY-MM-DD");
        const start = moment().format("YYYY-MM-DD");
        picker.$emit("pick", [start, end]);
      },
    },
    {
      text: "昨天",
      onClick(picker) {
        const end = moment().add(-1, "days").format("YYYY-MM-DD");
        const start = moment().add(-1, "days").format("YYYY-MM-DD");
        picker.$emit("pick", [start, end]);
      },
    },
    {
      text: "本周",
      onClick(picker) {
        const start =  moment().startOf("week").format("YYYY-MM-DD");
        const end = moment().endOf("week").format("YYYY-MM-DD")
        picker.$emit("pick", [start, end]);
      },
    },
    {
      text: "最近一周",
      onClick(picker) {
        const end = new Date();
        const start = new Date();
        start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
        picker.$emit("pick", [start, end]);
      },
    },
    {
      text: "本月",
      onClick(picker) {
        const start = moment().startOf("month").format("YYYY-MM-DD");
        const end = moment().endOf("month").format("YYYY-MM-DD");
        picker.$emit("pick", [start, end]);
      },
    },
    {
      text: "最近一个月",
      onClick(picker) {
        const end = new Date();
        const start = new Date();
        start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
        picker.$emit("pick", [start, end]);
      },
    },
    {
      text: "最近三个月",
      onClick(picker) {
        const end = new Date();
        const start = new Date();
        start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
        picker.$emit("pick", [start, end]);
      },
    },
    {
      text: "本年",
      onClick(picker) {
        const start = moment().startOf("year").format("YYYY-MM-DD");
        const end = moment().endOf("year").format("YYYY-MM-DD");
        picker.$emit("pick", [start, end]);
      },
    },
  ],
}